<?php
@session_start();
require_once('../config/config.php');
require_once('../utils/CommonUtils.php');
require_once('../utils/DBUtils.php');
include ("../utils/Constants.php");
require_once('../utils/BaseDAO.php');
require("../utils/Session.php");

$commonUtils = new CommonUtils();
$baseDAO = new BaseDAO();
$imageId = $commonUtils->getParameter("id");
$path = $commonUtils->getParameter("p");
$comments = $baseDAO->getItems("imagecomment", array("id", "content", "createddate", "createdby"), "status = 1 and imageid = " . $imageId, "order by createddate desc");
$userid = Session::get('userid');
?>
<?php foreach($comments as $comment){?>
<div class="comment">
	<span id="imgauthor"><?php echo $comment['createdby'] == null ? 'Không tên' : $comment['createdby'];?></span>
	<span id="imgdate" class="displayDate">&nbsp;<?php echo $commonUtils->timePost($comment['createddate']);?></span>
	<?php if(isset($userid) && $comment['createdby_id'] == $userid){?>
		<span id="imgdel"><a onclick="delcomment(<?php echo $comment['id'];?>);"><img src="<?php if(isset($path) && $path != ""){echo $path.'/';}?>css/images/delete.png"/></a></span>
	<?php }?>
	<div style="clear:both;"></div>
	<span id="imgcomment"><?php echo $comment['content'];?></span>
	<div style="clear:both;"></div>
</div>
<?php }?>